library(RPostgreSQL)
dr=dbDriver("PostgreSQL")


query="SELECT grdstation.id,avg(exp((550 - 500)*((log(grdaeraot_data.aod_675) - log(grdaeraot_data.aod_500))/(675-500)) + log(grdaeraot_data.aod_500))) FROM apom.grdaeraot_data,public.grdstation WHERE grdaeraot_data.stationid = grdstation.id AND grdaeraot_data.stationid IN (68,69,70,71,72,73,74) AND grdaeraot_data.aqstime BETWEEN '2013-01-02 04:00:00' and '2013-01-02 06:00:00' group by ( grdstation.id)"


con=dbConnect(dr,dbname="fimo",host="localhost",port=5432,user="postgres",password="123456")
rs=dbSendQuery(con,query)
#rs=dbSendQuery(con,"select * from \"GrdCEM_Station\"")
fetch(rs,n=-1)
